package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Department;
import cn.wolfcode.mapper.DepartmentMapper;
import cn.wolfcode.query.QueryObject;
import cn.wolfcode.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper ;

    public void delete(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    public Department selectOne(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }

    public void update(Department department) {
        departmentMapper.updateByPrimaryKey(department);
    }

    public PageInfo<Department> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize() );
        List<Department> list = departmentMapper.queryForList(qo);
        return new PageInfo<Department>(list);
    }
}
